package cn.kongwg.utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @author cn.kongwg
 * @create 2021-02-06 20:22
 */
public class MybatisUtils {


    private static SqlSessionFactory sessionFactory;

    static {
        InputStream is = MybatisUtils.class.getClassLoader().getResourceAsStream("mybatis-config.xml");

        sessionFactory = new SqlSessionFactoryBuilder().build(is);

    }

    public static SqlSession getSqlSession() {
        return sessionFactory.openSession();
    }
}
